#include <gtest/gtest.h>
#include "logger/logger.h"

TEST(test_log_file_line, test_log)
{
    EASE_INFO("file: %s, function: %s, line: %d", __FILE__, __FUNCTION__, __LINE__);
}

void logHandler(logger::LogLevel logLevel, const logger::MessageLogContext &context, const std::string &msg)
{
    EASE_INFO("log level: %d", (int) logLevel);
    EASE_INFO("file: %s, function: %s, line: %d", context.file, context.function, context.line);
    EASE_INFO("%s", msg.c_str());
}

TEST(test_log_install_log_message_no_format, test_log)
{
    logger::installMessageHandler(logHandler);
    EASE_DEBUG("debug ABCDEFG");
    EASE_INFO("info ABCDEFG");
    EASE_WARN("warning ABCDEFG");
    EASE_ERROR("error ABCDEFG");
    EASE_FATAL("fatal ABCDEFG");
}

TEST(test_log_install_log_message, test_log)
{
    logger::installMessageHandler(logHandler);
    EASE_DEBUG("debug ABCDEFG: %s, %d", "debug", 99);
    EASE_INFO("info ABCDEFG: %s", "1");
    EASE_WARN("warning ABCDEFG: %d", 12);
    EASE_ERROR("error ABCDEFG: %d", 23);
    EASE_FATAL("fatal ABCDEFG: %d", 34);
}

TEST(test_log_no_install_log_message_no_format, test_log)
{
    EASE_DEBUG("debug ABCDEFG");
    EASE_INFO("info ABCDEFG");
    EASE_WARN("warning ABCDEFG");
    EASE_ERROR("error ABCDEFG");
    EASE_FATAL("fatal ABCDEFG");
}

TEST(test_log_no_install_log_message, test_log)
{
    EASE_DEBUG("debug ABCDEFG: %s, %d", "debug", 99);
    EASE_INFO("info ABCDEFG: %s", "1");
    EASE_WARN("warning ABCDEFG: %d", 12);
    EASE_ERROR("error ABCDEFG: %d", 23);
    EASE_FATAL("fatal ABCDEFG: %d", 34);
}
